﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.SheepDeathCommand;
using SheepStorage.API.Application.Command.SheepMarkCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepDeathHandler
{
    public class SheepDeathSelectCommandHandler :IRequestHandler<SheepDeathSelectCommand,Results<Domain.DTO.Output.PageOutput<SheepDeathOutput>>>
    {
        private readonly ISheepDeathService _sheepDeathService;
        private readonly IMapper _mapper;

        public SheepDeathSelectCommandHandler(ISheepDeathService sheepDeathService, IMapper mapper)
        {
            _sheepDeathService = sheepDeathService;
            _mapper = mapper;
        }
        /// <summary>
        /// 戴标列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<Domain.DTO.Output.PageOutput<SheepDeathOutput>>> Handle(SheepDeathSelectCommand request, CancellationToken cancellationToken)
        {
            return Results<Domain.DTO.Output.PageOutput<SheepDeathOutput>>.DataResult(await _sheepDeathService.GetSheepDeaths(request.PageIndex, request.PageSize,Convert.ToString(request.Sdate),Convert.ToString(request.Edate),request.OverBit,request.SheepDeathReason));
        }

    }
}
